package com.zijidelu.luframework.generator;

import freemarker.template.Configuration;

/**
 * FreeMarkerFactory
 *
 * @author ZIJIDELU
 * @datetime 2025/10/24 11:56
 */
public class FreeMarkerFactory {
    public static final String FTL_PATH = "/templates/ftl";

    /**
     * 获取 FreeMarker 配置对象
     *
     * @return FreeMarker 配置对象
     */
    public static Configuration getFtlConfiguration() {
        // 创建 FreeMarker 配置对象
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_34);

        // 设置模板文件存放的目录
        cfg.setTemplateLoader(new freemarker.cache.ClassTemplateLoader(FreeMarkerFactory.class, FTL_PATH));

        // 设置默认的字符编码
        cfg.setDefaultEncoding("UTF-8");

        return cfg;
    }


}
